#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include "SerialGUI.h"

namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    bool loadPasswdFile(QString fileName);


public slots:
    void showConfig();
    void showHelp();

    void lockStatusChanged(bool isLocked);
    void checkStatusChanged(bool isChecked);
    void activateStatusChanged(bool isActivated);
    void configStatusChanged(bool isValid);

    void newMsgReceived(void);

    void setUnlockPassword(QString &pw);
    void setIgnitionPassword(QString &pw);

signals:
    void setLockStatus(bool isLocked);
    void setCheckStatus(bool isChecked);
    void setActivateStatus(bool isActivated);
    void setConfigStatus(bool isValid);

    void forceShutdownRemote(void);

private slots:

    void on_unlock_button_clicked();
    void on_activate_button_clicked();
    void on_stby_button_clicked();
    void on_check_button_clicked();

    void sendActivatePacket(void);

    void on_ignition_button_pressed();

private:
    Ui::MainWindow *ui;
    void closeEvent(QCloseEvent *);

    QTimer *activateTimer;
    int activateCount;
    static const int activateInterval = 1000;

    SerialGUI *uart;

    QString unlockPasswd;
    QString ignitionPasswd;

    static const int sendMsgDisplayTime = 2000;
};

#endif // MAINWINDOW_H
